<script setup lang="ts">
import menuStore from "@/piniaStore/menuStore.ts";
import showHideMenu from "@/piniaStore/showHideMenu.ts";
import {UserModel} from "@/interfaces/apiResponse.ts";

const router = useRouter()
const route = useRoute();
const menu = menuStore();
menu.init();
watch(route,()=>{
  menu.addHistoryMenus(route);
  menu.setCurrentMenu(route);
},{
  immediate:true
})
const info:UserModel = myLocalStore().get('userInfo');
if(info.is_super_admin == 'no' || !info.is_super_admin) router.push({name:'home'})
</script>

<template>
  <main class="all">
    <layout-menu/>
    <div class="content" :class="{'w-screen':!showHideMenu().show}">
      <div class="top">
        <layout-breadcrumb />
       <layout-history />
      </div>
      <div class="main relative overflow-y-auto">
        <router-view #default="{Component,route}">
          <component :is="Component" :key="route.fullPath" class="absolute w-full"/>
        </router-view>
      </div>

    </div>
  </main>

</template>

<style lang="scss" scoped>
main.all {
  @apply h-screen w-screen grid grid-cols-[auto_1fr];


  div.content {
    @apply bg-slate-200 text-gray-700 grid grid-rows-[auto_1fr];
    div.top {

    }

    div.main {
      @apply bg-white  mt-2;
    }
  }
}
</style>